    $(function(){
        init();
        e();
    });
    var myScroll,slider,codeFlag = true;
    function init(){
        myScroll = new IScroll('.alert-cont',{
            mouseWheel: true,
            scrollbars: true
        });
    }

    // 关闭（要离开网站吗？） 确认弹窗
    $(function(){ $(window).unbind('beforeunload'); window.onbeforeunload = null; });


    var flag_reg = false;
    function e(){
        // 信息（用户注册协议）弹窗
        $(".btn_rule").on("click",function(){
            $(".alert-box").fadeIn();
            myScroll.refresh();
        });
        // 关闭（用户注册协议）弹窗
        $(".alert-close").on("click",function(){
            $(".alert-box").fadeOut();
        });
        // 注册提交
        $(".form-btn1").on("click",function(){
            var ip = $('.part2 .input-phone').val();
            var regBox = {
                regMobile: /^0?1[3|4|5|7|8][0-9]\d{8}$/,
            };
            var mflag = regBox.regMobile.test(ip);
            if(!mflag) {
                return false;
            }
            var sms_code = $(".le-register-form .input-code").val();
            if (!sms_code){
                return false;
            }
        });
        // 点击获取验证码
        /*
        $(".btn-send-code").mousedown(function(){
            if(!flag_reg){
                slideBtn();
            }else{
                btnCodeTimeOut();
            }
        });
        */
    }
    //预设（获取验证码）无法点击
    //     $(".le-register-form .input-code").attr("disabled",true);
    //     //错误信息提示
    function le_error_message(le_position,message){
        if($("div").hasClass("le-error-message")){
            $(le_position).text(message).fadeIn();
            $(le_position).delay(2000).fadeOut();
        }
    }
    // 如果点击（清除手机号）按钮，则轻清空输入
    $(".le-clean-phone").click(function(){
        $(".input-phone").val("");
    });
    // 验证是否正确填写电话
    $( ".input-phone" ).focusout(function(){
        var mobile = $(".input-phone").val();
        if(!mobile){
            le_error_message(".le-number>.le-error-message","手机号码不能为空");
            return false;
        }
        if(!(/^1[34578]\d{9}$/.test(mobile))){
            le_error_message(".le-number>.le-error-message","手机号码格式有误，请重新输入");
            return false;
        }
    });

    //验证表单，是否正确填写验证码
    $( ".no_poup_registor .input-code" ).focusout(function(){
        var mobile = $(".input-phone").val(),
            code = $(".input-code").val();

        if(!mobile){
            return false;
        }
        if(!(/^1[34578]\d{9}$/.test(mobile))){
            return false;
        }
        if(!code){
            le_error_message(".le-code>.le-error-message","验证码不能为空");
            return false;
        }

        //code_type =  1 因为在资料库的资料表当中，1为「注册」类型

        var post = {'mobile':mobile,'code':code,'code_type':1};
        $.ajax({

            //url: "index.php?s=user&c=register&m=check_mobile_code" , 连结到指定档案中的该class
            //check_mobile_code为class名称，register为php名称

            type: "POST",dataType:"json", url: "index.php?s=user&c=register&m=check_mobile_code", data: post,
            success: function(data) {

                //用此条方法可验证，资料有无取得
                //console.log("data: "+data);return false;
                // 目前进行到此步骤时，data为null
                //console.log("data.status: "+data.status);return false;

                if (data.status) {
                    le_error_message(".le-code>.le-error-message","验证码输入正确");

                    // 验证成功后跳转页面。并且跳转信息框为灰
                    
                    $(".le-register-form .form-btn").text("即将跳转信息页面...").css("background","rgb(189, 189, 189)").css("font-size","16px");
                    
                    //延迟两秒跳转画面
                    
                    setTimeout(function () {
                        window.location.href = "index.php?s=user&c=register&m=register_info&mobile="+mobile+"&code="+code;
                    }, 2000);


                } else {
                    $('#dr_code_img').click();
                    le_error_message(".le-code>.le-error-message","验证码输入错误，请重新输入");
                    dr_tips(data.code,3,1);
                }
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                alert(HttpRequest.responseText);
            }
        });
    });

    //弹窗-验证表单，是否正确填写验证码
    $( ".poup_registor .input-code" ).focusout(function(){
        var mobile = $(".input-phone").val(),
            code = $(".input-code").val();

        if(!mobile){
            return false;
        }
        if(!(/^1[34578]\d{9}$/.test(mobile))){
            return false;
        }
        if(!code){
            le_error_message(".le-code>.le-error-message","验证码不能为空");
            return false;
        }

        //code_type =  1 因为在资料库的资料表当中，1为「注册」类型

        var post = {'mobile':mobile,'code':code,'code_type':1};
        $.ajax({
            type: "POST",dataType:"json", url: "index.php?s=user&c=register&m=check_mobile_code", data: post,
            success: function(data) {

                if (data.status) {
                    le_error_message(".le-code>.le-error-message","验证码输入正确");
                    $(".le-register-form .form-btn").text("即将跳转信息页面...").css("background","rgb(189, 189, 189)").css("font-size","16px");
                    setTimeout(function () {
                        window.location.href = "index.php?s=user&c=register&m=poup_register_info&mobile="+mobile+"&code="+code;
                    }, 2000);
                }

                else {
                    $('#dr_code_img').click();
                    le_error_message(".le-code>.le-error-message","验证码输入错误，请重新输入");
                    dr_tips(data.code,3,1);
                }

            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                alert(HttpRequest.responseText);
            }
        });
    });


    //滑动事件
    function slideBtn() {
        var ip = $('.part2 .input-phone').val();
        var regBox = {
            regMobile: /^0?1[3|4|5|7|8][0-9]\d{8}$/, //手机
            //			regTel: /^0[\d]{2,3}-[\d]{7,8}$/
        };
        var mflag = regBox.regMobile.test(ip);
        //		var tflag = regBox.regTel.test(ip);
        if(mflag) {
            if(codeFlag){
                $(".slide-box").fadeIn();

                var $container = $('#foo');
                $container.slideToUnlock({
                    width: 360,
                    height: 60,
                    bgColor:'rgba(117, 164, 254, 0)',
                    handleColor:'rgba(117, 164, 254, 0)',
                    succColor:'rgba(117, 164, 254, 0)',
                    text:'',
                    textColor:'rgba(117, 164, 254, 0)',
                    succText:'解锁成功',
                    successFunc: function() {
                        // alert('successfully unlock!');
                        // 解锁成功
                        setTimeout(function(){
                            //开始验证
                            //$("#foo").html("<div style='text-align: center;'>解锁成功</div>");
                            //$(".slide-box").delay(3000).fadeOut();
                            $(".slide-box").fadeOut();
                            flag_reg = true;
                            $(".le-register-form .input-code").attr("disabled",false);                  //开始验证后才可输入验证码
                            $(".le-clean-code").click(function(){ $(".input-code").val(""); });          //可以清除验证码
                            btnCodeTimeOut();
                            //btnCodeAc();
                        },300);
                    }
                });
                codeFlag = false;
            }

        }else{
            return false;
        }
    }
    // 防作弊的图形验证码检验正确
    function btnCodeAc(){
        $(".btn-code").addClass("on");
    }
    function btnCodeCancleAc(){
        $(".btn-code").removeClass("on");
    }
    // 验证码60秒倒计时
    var codeTime = 60;
    function btnCodeTimeOut(){
        $(".btn-code").addClass("off").html(codeTime+"s");
        sms_send();
        var timer = setInterval(function(){
            codeTime--;
            $(".btn-code").html(codeTime+"s");
            if(codeTime < 1){
                clearInterval(timer);
                $(".btn-code").html("获取验证码");
                $(".btn-code").removeClass("off");
                codeTime = 60;
            }
        }, 1000);

    }
    //发送短信验证码
    function sms_send(){
        var mobile = $('.part2 .input-phone').val();
        var regBox = {
            regMobile: /^0?1[3|4|5|7|8][0-9]\d{8}$/, //手机
        };
        var mflag = regBox.regMobile.test(mobile);
        var post = {"phone":mobile,"is_type":1};
        if(mflag){
            $.ajax({
                type: "POST",dataType:"json", url: "index.php?s=user&c=async&m=sms_send", data: post,
                success: function(data) {
                    if (data.status) {
                        dr_tips('发送验证码成功....', 3, 1);
                    } else {
                        //提示（发送验证次数过多）
                        le_error_message(".le-code>.le-error-message",data.msg);
                    }
                },
                error: function(HttpRequest, ajaxOptions, thrownError) {
                    alert(HttpRequest.responseText);
                }
            });
        }else{
            return false;
        }
    }
    // 是否勾选用户协议
    var isRead = true;
    $(".form-btn3").on("click",function(){
        if(isRead){
            $(".form-btn3").removeClass("on");
            $(".form-btn3").removeAttr("id");
            $(".form-btn1").attr("disabled",false);
            isRead = false;
        }else{
            $(".form-btn3").addClass("on");
            $(".form-btn3").attr("id","agree");
            $(".form-btn1").attr("disabled",true);
            isRead = true;
        }
    });

    $(".form-btn3 a").on("click",function(e){
        window.event? window.event.cancelBubble = true : e.stopPropagation();
        $(".form-btn3").addClass("on");
        isRead = true;
    });

    var flags = false;
    $(".form-btn1").on("click",function(){
        //判断是否同意协议
        if(!$(".form-btn3").find('id')){
            le_error_message("#user_register_form > .le-error-message","请选择同意该协议之后，再提交");
            return false;
        }
    });

    //此为注册后选择课程...的表单
    $(".register_submit").on("click",function(){
        var name = $("input[name='name']").val(),
            code = $("input[name='code']").val(),
            mobile = $("input[name='mobile']").val(),
            grade = $("select[name='grade']").val(),
            subject = $("select[name='subject']").val();
        if(!mobile){
            le_error_message(".le-number>.le-error-message","手机号码不能为空");
            return false;
        }
        if(!(/^1[34578]\d{9}$/.test(mobile))){
            le_error_message(".le-number>.le-error-message","手机号码格式有误，请重新输入");
            return false;
        }
        if(!name){
            le_error_message(".le-error-message","姓名不能为空");
            return false;
        }
        if(!grade){
            le_error_message(".le-error-message","年级不能为空");
            return false;
        }
        if(!subject){
            le_error_message(".le-error-message","课程不能为空");
            return false;
        }
        var post = {'name':name,'code':code,"mobile":mobile,"grade":grade,"subject":subject};
        $.ajax({
            type: "POST",dataType:"json", url: "", data: post,
            success: function(data) {
                if (data.status) {
                    $(".register_submit").text("注册成功，即将为您跳转....").css("background","rgb(189, 189, 189)").css("font-size","16px");
                    setTimeout('window.location.href="'+data.backurl+'"', 2000);
                } else {
                    $('#dr_code_img').click();
                    dr_tips(data.code,3,1);
                }
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                alert(HttpRequest.responseText);
            }
        });
    });

    $(".forget_submit").on("click",function(){
        var phone = $(".input-phone").val(),
            code = $(".input-code").val(),
            pass = $(".input-repassword").val();
        if(!phone){
            le_error_message(".le-number>.le-error-message","手机号码不能为空");
            return false;
        }
        if(!(/^1[34578]\d{9}$/.test(phone))){
            le_error_message(".le-number>.le-error-message","手机号码格式有误，请重新输入");
            return false;
        }
        if(!code){
            le_error_message(".le-code>.le-error-message","验证码不能为空");
            return false;
        }
        if(!pass){
            le_error_message(".le-error-message","新密码不能为空");
            return false;
        }

        var post = {"phone":phone,"code":code,"pass":pass};
        $.ajax({
            type:"POST",dataType:"json",url:"",data:post,
            success:function (data) {
                if(data.status){
                    dr_tips('找回密码成功，即将为您跳转....', 3, 1);
                    setTimeout('window.location.href="'+data.id+'"');
                }
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                alert(HttpRequest.responseText);
            }
        });
        // window.location.href = "register_sus.html";
    })
    //失去焦点查询号码是否存在
    $("#register_phone").blur(function(){
        var phone = $(this).val();
        if(!phone){
            le_error_message(".le-number>.le-error-message","手机号码不能为空");
            return false;
        }
        if(!(/^1[34578]\d{9}$/.test(phone))){
            le_error_message(".le-number>.le-error-message","手机号码格式有误，请重新输入");
            return false;
        }
        var post = {'phone':phone};
        $.ajax({
            type:"POST",dataType:"json",url:'index.php?s=user&c=register&m=check_phone',data:post,
            success:function (data) {
                if(data.status){
                    // $(".input-phone").addClass("error").attr('placeholder','该手机号码已经注册请重新输入');
                    dr_tips('该手机号码已经注册，请重新输入', 3, 1);
                }else{
                    $(".btn-send-code").mousedown(function(){
                        if(!flag_reg){
                            slideBtn();
                        }else{
                            btnCodeTimeOut();
                        }
                    });
                    dr_tips(data.msg,3);
                }
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                alert(HttpRequest.responseText);
            }
        });
    });